<template>
	<view class="content">
		<view class="accept-box">
			<image class="inv-top" src="@/static/img/inv-top2.png" mode="widthFix"></image>
			<view class="item-phone">您的好友{{ mobile }}为您推荐法力</view>
			<image class="inv-bot" src="@/static/img/inv-bot.png" mode="aspectFit"></image>
			<view class="coupon-new">
				<image src="@/static/img/coupon-share.png" mode="widthFix"></image>
			</view>
			<view class="inv-bot-ipt-box">
				<input type="number" v-model="acceptMobile" maxlength="11" placeholder="请输入您的手机号码"
					placeholder-style="font-size:24rpx" />
				<view class="item-txt" @click="changeShow()">我要领券</view>
			</view>
		</view>
		<div class="iframe-container" id="iframe-container">
			<!--:class="small?'anzhuoheight top_200':'top_200'" 原来的 -->
			<iframe scrolling="no" style="overflow-y:scroll;width:100%;height:460vh"
				src="https://d-fali.bigchun.com/web/tui.html" ref="iframe" frameborder="0" @load="calAutoHeight($event)"
				id="outerPage"></iframe>

		</div>
		<!--		<view class="ad-box" v-if="topheight">-->
		<!--      <web-view class="top_200" :class="small?'anzhuoheight':''" :style="{top:topheight+'px!important'}" src="https://d-fali.bigchun.com/web/tui.html"></web-view>-->
		<!--    </view>-->
		<!-- 全局通用组件 -->
	</view>
</template>

<script>
	import $ from 'jquery';
	export default {
		data() {
			return {
				order_id: '',
				mobile: '',
				acceptMobile: '',
				topheight: '',
				small: false
			};
		},
		onLoad(options) {
			let routes = getCurrentPages();
			let curParam = routes[routes.length - 1].options;
			this.order_id = curParam.order_id;
			this.getInvite();
			$('.content').height()
		},
		created() {
			// 安卓
			window.isRightsOk = this.isRightsOk;
			const nav = navigator.userAgent;
			if (nav.indexOf("Android") > -1 || nav.indexOf("Adr") > -1) {
				this.small = true;
			} else if (!!nav.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)) {
				this.small = false;
			}
			setTimeout(() => {
				this.topheight = $('.content').height();
				// this.$refs.iframe
				this.$refs.iframe.style.overflow = "hidden";
				// //console.log(this.$refs.iframe,  $(this.$refs.iframe).contents().find("document"),"===========height()1111",$('.content').height(),this.small,nav,!!nav.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),(nav.indexOf("Android") > -1 || nav.indexOf("Adr") > -1))
			}, 1200)
		},
		methods: {
			calAutoHeight(e) {
				var iframe = document.getElementById("#outerPage");
				// iframe.height = $("#outerPage").contents().find(document.body).height();
				//console.log($("#outerPage").contents().find(document.body), "====loading", e, )
				// //console.log( $("iframe").contents().find("body").css(),$("iframe").contents().find("body").height(),"===========height()1111",$('.content').height())

			},
			getInvite() {
				let formData = {
					id: this.order_id,
					type: 2
				};
				this.$api('index.my_inviteCode', formData).then(res => {
					this.mobile = res.data.mobile;
				});
			},
			changeShow() {
				if (!/(^1[0-9]{10}$)/.test(this.acceptMobile)) {
					uni.showToast({
						title: '请输入正确的手机号',
						icon: 'none'
					});
					return;
				}
				this.$api('index.get_coupon', {
					id: this.order_id,
					mobile: this.acceptMobile
				}).then(res => {
					if (res.code == 1) {
						uni.showToast({
							title: '您已领劵，快下载APP咨询律师吧',
							icon: 'none'
						});
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						});
					}
					setTimeout(() => {
						 this.replace('/pages/client/order/order-court-down');
						// window.location.href =
						// 	'https://a.app.qq.com/o/simple.jsp?pkgname=com.lifakeji.lark.business.law';
					}, 2000);
				});
			}
		}
	};
</script>

<style lang="scss">
	.accept-box {
		width: 100%;
		height: 100%;
		background-color: #e11b3c;
		padding-bottom: 120rpx;
		width: 100%;

		.inv-top {
			width: 100%;
		}

		.inv-bot {
			display: block;
			margin: 60rpx auto;
			height: 60rpx;
		}

		.item-phone {
			color: #ffffff;
			font-size: 30rpx;
			margin-top: 40rpx;
			text-align: center;
			font-weight: bold;
			text-shadow: 0 4rpx 10rpx rgba(0, 0, 0, 0.4);
		}

		.inv-bot-ipt-box {
			display: flex;
			margin: 0 auto;
			width: calc(100% - 160rpx);
			background-color: #ffffff;
			border-radius: 10rpx;
			align-items: center;

			input {
				flex: 1;
				font-size: 28rpx;
				padding: 10rpx;
			}

			.item-txt {
				padding: 15rpx 20rpx;
				border-radius: 10rpx;
				color: #ffffff;
				text-align: center;
				background: linear-gradient(to right, #9730E9, #5100B8);
			}
		}
	}

	.ad-box {
		width: 750rpx;
		background-image: url(https://oss.bigchun.com/fali/uploads/20210810/85da656fb99f0dded7b5ce93e16cc177.jpg);

		image {
			width: 640rpx;
			padding: 55rpx;
		}
	}

	.coupon-new {
		width: 400rpx;
		margin: 0 auto 30rpx;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.top_200 {
		position: absolute;
		overflow: hidden;
		height: 400vh !important;
		width: 100%;
	}

	.anzhuoheight {
		height: 420vh !important;
	}
</style>
